import axios from 'axios'

export const baseURL = 'http://10.7.162.150:8089'
const axiosServer = axios.create({
	baseURL,
	timeout: 5000,
})

//请求拦截器
axiosServer.interceptors.request.use(
	config => {
		let token = localStorage.getItem('TOKEN')
		if (token) {
			config.headers['Authorization'] = token;
		}
		
		return config
	},
	error => {
		return Promise.reject(error)
	}
)

//响应拦截器
axiosServer.interceptors.response.use(
	function (response) {
		return response.data
	},
	function (error) {
		return Promise.reject(error)
	}
)
export default axiosServer
